#include "mainwindow2.h"
#include "ui_mainwindow2.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
mainwindow2::mainwindow2(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::mainwindow2)
{
    ui->setupUi(this);
    setWindowTitle("智能家居系统主界面");
    ui->listWidget->addItem("数据");
    ui->listWidget->addItem("控制");
    ui->listWidget->addItem("曲线图");
    //实例化三个界面
    mainWindow3 = new mainwindow3;
    mainWindow4 = new mainwindow4;
    mainWindow5 = new mainwindow5;
    ui->stackedWidget_2->addWidget(mainWindow3);
    ui->stackedWidget_2->addWidget(mainWindow4);
    ui->stackedWidget_2->addWidget(mainWindow5);
    connect(ui->listWidget, &QListWidget::currentRowChanged,
            ui->stackedWidget_2, &QStackedWidget::setCurrentIndex);
    //    //mqtt相关
    //    MqttHandler *mqtt = new MqttHandler;
    //    GlobalVal::mqtt = mqtt;
    //    mqtt->setHost(QHostAddress("127.0.0.1"));
    //    mqtt->setPort(1883);
    //    mqtt->connectToHost();

    //哪个界面需要接收Mqtt的消息，就订阅这个信号，然后在自己的界面文件中处理消息
    //    QObject::connect(mqtt, SIGNAL(dataUpSignal(QByteArray)),
    //                     modbusWig, SLOT(dataUpSlot(QByteArray)));
}

mainwindow2::~mainwindow2()
{
    delete ui;
}
